package com.function;

import com.function.domain.CallmeEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;

@Configuration
public class StreamFunction {

    static AtomicInteger id=new AtomicInteger(1);
    @Bean
    public java.util.function.Supplier<Message<CallmeEvent>> callmeEventSupplier() {

        return () -> {
              Message<CallmeEvent> build = MessageBuilder.withPayload(new CallmeEvent(id.getAndIncrement(), "I'm callme event!"))
                    .setHeader("to_process", true)
                    .build();
              return build;
        };
    }

}
